package models

type Tag struct {
	ID         int    `gorm:"primary_key" json:"id"`
	Name       string `json:"name"`
	CreatedBy  string `json:"created_by"`
	ModifiedBy string `json:"modified_by"`
	Time       string `json:"time"`
}

func GetTag(maps interface{}) (tags []Tag) {
	db.Where(maps).Find(&tags)
	return tags
}

func InsertTag(maps map[string]interface{}) error {
	tag := Tag{
		Name:      maps["Name"].(string),
		CreatedBy: maps["CreatedBy"].(string),
		Time:      maps["Time"].(string),
	}
	if err := db.Model(&Tag{}).Create(&tag).Error; err != nil {
		return err
	}
	return nil
}

func DelTag(id int) error {
	if err := db.Where("id = ?", id).Delete(&Tag{}).Error; err != nil {
		return err
	}
	return nil
}
